import request from "@/utils/requests";

// 登录api
const loginApi = async (data) =>
    await request("/admin/login", { method: "POST", data }),
  // 获取用户信息Api
  infoApi = async () => await request("/admin/adminInfo", { method: "GET" }),
  // 退出登录Api
  logoutApi = async () =>
    await request("/admin/admin/logout", { method: "GET" }),
  // 获取用户信息Api
  changePasswordApi = async (data) =>
    await request("/user/change", { method: "POST", data }),
  // 根据分类显示商品
  classifyApi = async (data) =>
    await request("/admin/classify", { method: "GET", data }),
  // 添加分类
  addclassifyApi = async (data) =>
    await request("/admin/classify/add", {
      method: "POST",
      headers: { "Content-Type": "multipart/form-data" },
      data,
    }),
  // 修改分类
  editClassifyApi = async (data) =>
    await request("/admin/classify/edit", { method: "PUT", data }),
  // 进货
  goodsApi = async (data) => await request("/goods", { method: "GET", data }),
  // 添加进货信息
  addStockApi = async (data) =>
    await request("/admin/stock/add", { method: "POST", data }),
  // 渲染进货历史
  stockApi = async (data) =>
    await request("/admin/stock", { method: "POST", data }),
  // 后台首页
  home = async () => await request("/admin/admin/home", { method: "GET" }),
  // 管理员个人信息
  adminInofApi = async () =>
    await request("/admin/adminInfo", { method: "GET" }),
  //修改个人信息
  emitAdmin = async (data) =>
    await request("/admin/admin/edit", { method: "POST", data }),
  //显示所有管理员的信息
  adminRenderApi = async () => await request("/admin/admin", { method: "GET" }),
  // super修改其他管理员个人信息
  editAdminInfoApi = async (values) =>
    await request("/admin/admin/editInfo", {
      method: "POST",
      data: values,
    }),
  // super添加管理员
  addAdminApi = async (data) =>
    await request("/admin/admin/add", {
      method: "POST",
      data,
    }),
  //super删除管理员
  delAdminApi = async (data) =>
    await request("/admin/admin", {
      method: "DELETE",
      data: { id: data },
    }),
  //显示订单信息
  lookIndentList = async (data) =>
    await request("/admin/indent/list", { method: "POST", data }),
  // 发货
  shipApi = async (data) =>
    await request("/admin/indent/shipped", {
      method: "POST",
      data,
    }),
  // 获取会员列表
  get_user_list = async () =>
    await request("/admin/get_user_list", { method: "GET" }),
  // 删除会员
  delete_user = async (data) =>
    await request("/admin/delete_user", { method: "POST", data }),
  // 启用/禁用会员
  update_status = async (data) =>
    await request("/admin/update_status", { method: "POST", data }),
  reset_password = async (data) =>
    await request("/admin/reset_password", { method: "POST", data });

export {
  adminRenderApi,
  delAdminApi,
  addAdminApi,
  editAdminInfoApi,
  lookIndentList,
  shipApi,
  home,
  adminInofApi,
  emitAdmin,
  loginApi,
  infoApi,
  logoutApi,
  changePasswordApi,
  classifyApi,
  editClassifyApi,
  goodsApi,
  addclassifyApi,
  stockApi,
  addStockApi,
  get_user_list,
  delete_user,
  update_status,
  reset_password,
};
